<?php
/*
 * @Author: your name
 * @Date: 2020-12-24 18:12:12
 * @LastEditTime: 2020-12-24 18:21:21
 * @LastEditors: Please set LastEditors
 * @Description: 排序防火墙规则
 * @FilePath: /special/application/api/controller/netfilter/FirewallRuleSortController.php
 */
namespace app\api\controller\netfilter;

use app\adminapiv3\service\module_manage\netfilter\RulePreviewService;
use app\api\controller\BaseController;
use app\common\exception\CustomException;

class FirewallRuleSortController extends BaseController
{
    /**
     * @name: 规则排序组件推送排序后规则接口
     * @Param: 
     * @Description: (该规则不验证用户权限)但是仅供本地规则排序组件调用!!!!
     * @Author: foo
     * @Date: 2020-11-30 10:35:04
     */
    public function autoSort (\think\Request $request)
    {
        if($request->host(true) != '127.0.0.1')
        {
            throw new CustomException('本接口仅限于排序组件访问,你的访问地址为:' . $request->host(true), 500);
        }
        
        $raw = $request->getInput();
        $input = json_decode($raw, true);

        $RulePreviewService = new RulePreviewService();
        $RulePreviewService->rankFirewallRule($input);

        return $this->jsonOutPut();
    }
}
